﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iTunesAutomator
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            textBox1.Text = FileManager.GetLastFilePath();
        }

        // Clicked the 'Browse' button.
        private void button1_Click(object sender, EventArgs e)
        {
            var result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                textBox1.Text = folderBrowserDialog1.SelectedPath;
                FileManager.WriteLastFilePath(folderBrowserDialog1.SelectedPath);
            }
        }

        // Clicked the 'Start' button.
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == String.Empty)
            {
                MessageBox.Show("Browse to your music folder first.");
            }
            else
            {
                iTunesController.CreatePlaylistsFromFolder(textBox1.Text, textBox2);
            }
        }

        // Clicked the 'Clear Log' button.
        private void button3_Click(object sender, EventArgs e)
        {
            textBox2.SelectionStart = textBox2.TextLength;
            textBox2.SelectionLength = 0;
            textBox2.SelectedText = "";
            textBox2.ScrollToCaret();
            textBox2.Text = "";
        }
    }
}
